{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "polyphonic-salon",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [4, 5, 6],\n",
       "       [7, 8, 9]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "a = np.array((1, 3,5,6,8))\n",
    "\n",
    "a = np.array([(1,2,3), (4,5,6), (7,8,9)])\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "hollow-mumbai",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 1., 0., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 1., 0., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 1., 0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 1., 0., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 1., 0., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 1., 0.],\n",
       "       [0., 0., 0., 0., 0., 0., 0., 1.]])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.eye(8)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "adaptive-cowboy",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[ 0.33523567, -0.89300951,  0.54474571, -0.16897105,\n",
       "          1.57720681],\n",
       "        [-0.44533792, -0.10057335,  0.354887  , -1.33996188,\n",
       "          0.81035458],\n",
       "        [ 1.28879034,  1.38705904,  1.00365687, -0.44039776,\n",
       "         -0.42839495],\n",
       "        [ 1.0855877 , -0.95118804, -0.41558584, -0.03048475,\n",
       "          0.09214207]],\n",
       "\n",
       "       [[-0.08914932,  0.1396236 , -1.1547647 ,  2.14346748,\n",
       "         -1.9898447 ],\n",
       "        [ 1.90225048, -0.03858281,  1.33708449,  1.53426272,\n",
       "         -0.15646944],\n",
       "        [ 0.52545318, -0.43356954,  0.3667481 ,  0.32715954,\n",
       "         -1.0738707 ],\n",
       "        [ 1.22049971, -0.35284927, -0.79211435,  0.96925758,\n",
       "         -0.39443461]],\n",
       "\n",
       "       [[ 1.03252441, -0.1543825 ,  0.20870585,  1.25567985,\n",
       "          0.95179092],\n",
       "        [ 1.05784863, -0.27293362,  0.66435257,  1.94218231,\n",
       "         -1.61993063],\n",
       "        [ 0.26170573, -0.55938802,  1.20696937, -1.4404424 ,\n",
       "          0.43267477],\n",
       "        [ 1.86049008,  1.65287897, -0.36736547,  0.72378431,\n",
       "          0.20073463]]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.random.randn(60).reshape((3,4,5))\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "signed-raise",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 2, 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 2, 2, 2, 2, 1, 2, 0, 1, 0, 0,\n",
       "       0, 0, 1, 0, 2, 1, 2, 1, 0, 1, 2, 0, 0, 2, 0, 0, 2, 0, 0, 1, 2, 2,\n",
       "       1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 2, 0, 1, 2, 2, 0, 1, 0, 0, 0, 0,\n",
       "       1, 0, 1, 1, 0, 0, 0, 2, 2, 2, 1, 0, 0, 0, 2, 1, 1, 2, 1, 1, 2, 2,\n",
       "       0, 1, 1, 1, 0, 2, 0, 1, 0, 1, 0, 2])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b = np.random.randint(0,3,size=100)\n",
    "\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "minus-collapse",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "60"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.arange(60).reshape((3,4,5))\n",
    "a.size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "stuffed-nevada",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.        , 0.10526316, 0.21052632, 0.31578947, 0.42105263,\n",
       "       0.52631579, 0.63157895, 0.73684211, 0.84210526, 0.94736842,\n",
       "       1.05263158, 1.15789474, 1.26315789, 1.36842105, 1.47368421,\n",
       "       1.57894737, 1.68421053, 1.78947368, 1.89473684, 2.        ])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.linspace(0, 2, 20) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "raised-parallel",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "float64\n",
      "int32\n"
     ]
    }
   ],
   "source": [
    "# 默认数据类型是float64\n",
    "a = np.ones((3,4))\n",
    "\n",
    "# 可以指定数据类型\n",
    "b = np.ones((3,4), dtype='int32')\n",
    "print(a.dtype)\n",
    "print(b.dtype)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "encouraging-burning",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
